Skip to content

Fix get_dummy_wan_inputs for two-expert Wan2.2-I2V-A14B pipeline#427

Open
ThomasNing wants to merge 1 commit into
AI-Hypercomputer:mainfrom
ThomasNing:fix/wan22-i2v-2.2-quant-dummy-inputs
Open

Fix get_dummy_wan_inputs for two-expert Wan2.2-I2V-A14B pipeline#427
ThomasNing wants to merge 1 commit into
AI-Hypercomputer:mainfrom
ThomasNing:fix/wan22-i2v-2.2-quant-dummy-inputs

Conversation

@ThomasNing

Copy link
Copy Markdown

Problem

get_dummy_wan_inputs (called by WanPipeline.quantize_transformerqwix.quantize_model) assumes a single pipeline.transformer and the single-transformer prepare_latents() signature. The two-expert WanPipelineI2V_2_2 (Wan2.2-I2V-A14B) has low_noise_transformer / high_noise_transformer (no .transformer) and a different prepare_latents() signature, so use_qwix_quantization=True crashes:

AttributeError: 'WanPipelineI2V_2_2' object has no attribute 'transformer'

and, once that's worked around:

TypeError: WanPipelineI2V_2_2.prepare_latents() got an unexpected keyword argument 'vae_scale_factor_temporal'

Fix

When pipeline.transformer is absent (two-expert pipeline), build the dummy latents directly in the (B, C, F, H, W) layout WanModel.__call__ expects, taking num_channels_latents from an existing expert (low_noise_transformer). The single-transformer path is unchanged.

Validation

On Wan2.2-I2V-A14B (TPU v6e-16, 1080p, 4-step): with this change, quantization proceeds past both errors above into qwix.quantize_model (the model forward traces correctly with (latents, timesteps, prompt_embeds)). A separate qwix↔JAX version issue (conv_general_dilated() got an unexpected keyword argument 'out_sharding') then surfaces in our environment — unrelated to this change.

@ThomasNing ThomasNing requested a review from entrpn as a code owner June 24, 2026 01:00
@google-cla

google-cla Bot commented Jun 24, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Comment thread src/maxdiffusion/maxdiffusion_utils.py Outdated

@Perseus14 Perseus14 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I have added a comment, PTAL!

@ThomasNing

Copy link
Copy Markdown
Author

@Perseus14 Hi Rishabh, could you take another look?

@Perseus14

Copy link
Copy Markdown
Collaborator

LGTM!

Could you please run this linting check? For some reason that test is not being triggered.

pip install pylint pyink==23.10.0 pytype==2024.2.27
pyink src/maxdiffusion --check --diff --color --pyink-indentation=2 --line-length=125

If no errors, will approve the PR

@ThomasNing

Copy link
Copy Markdown
Author

Ran it on the branch:

$ pyink src/maxdiffusion --check --diff --color --pyink-indentation=2 --line-length=125
294 files would be left unchanged.

Exit 0, no diffs — the two changed files (maxdiffusion_utils.py and its test) are clean too. Should be good to go. 🙏

@Perseus14

Perseus14 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

@ThomasNing Looks like one of the email used in the commits of this PR hasn't signed the google cla. Please rebase and squash commits with the right email

Derive the dummy-input channel count from whichever expert exists on the
two-expert I2V-2.2 pipeline (low/high_noise_transformer) instead of the
absent single pipeline.transformer, and generate the dummy WAN latents
uniformly so quantization calibration works for this pipeline.
@ThomasNing ThomasNing force-pushed the fix/wan22-i2v-2.2-quant-dummy-inputs branch from 6212212 to 952aa1e Compare July 2, 2026 07:33
@ThomasNing

Copy link
Copy Markdown
Author

@Perseus14 Passed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants